#include "common.h"
#include "PlainPolygonRenderer.h"


using namespace Scenic::Renderer;


PlainPolygonRenderer::PlainPolygonRenderer(Context *context)
{
	this->context = context;
	vs = new VertexStore(VSF_TEX0, context, 0);
}

PlainPolygonRenderer::~PlainPolygonRenderer()
{
	delete vs;
}

void PlainPolygonRenderer::begin()
{
	context->setPrimitives(0);
	context->device->setBlendFunc(BLEND_ONE, BLEND_ONE_MINUS_SRC_ALPHA);
}

void PlainPolygonRenderer::end()
{
	vs->endBlock();
	vs->draw();
}

void PlainPolygonRenderer::addPoint(double x, double y)
{
	vs->addVertex(x, y, context->color.getRGBA32());
}

void PlainPolygonRenderer::addTriangle(int vertex1, bool edge1, int vertex2, bool edge2, int vertex3, bool edge3)
{
	vs->addTriangle(vertex1, vertex2, vertex3);
}

